package cn.edu.scujcc.myproject.ui.home;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;

import cn.edu.scujcc.myproject.R;
import cn.edu.scujcc.myproject.StartActivity;
import cn.edu.scujcc.myprojecttest.LibraryLoginActivity;

public class HomeFragment extends Fragment {

    private HomeViewModel homeViewModel;
    private Button button1;
    private RecyclerView channelRV;
    private Context context;
    private Button button2;

    public View onCreateView(
            @NonNull LayoutInflater inflater,
            ViewGroup container, Bundle savedInstanceState) {
        homeViewModel =
                new ViewModelProvider(this).get(HomeViewModel.class);
        View root = inflater.inflate(R.layout.fragment_home, container, false);
        button1 = root.findViewById(R.id.button);//id后面为上方button的id
        button2 =root.findViewById(R.id.button2);
//
//        channelRV=root.findViewById(R.id.channel_rv);
//        ChannelRvAdapter rvAdapter=new ChannelRvAdapter();
//        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(getContext());
//        channelRV.setLayoutManager(linearLayoutManager);
//        channelRV.setAdapter(rvAdapter);
//        channelRV.setLayoutManager(new LinearLayoutManager(getContext()));

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(getActivity(),StartActivity.class);//this前面为当前activty名称，class前面为要跳转到得activity名称
                startActivity(intent);

            }

        });
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(getActivity(), LibraryLoginActivity.class);//this前面为当前activty名称，class前面为要跳转到得activity名称
                startActivity(intent);

            }

        });

//        channelRV.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                ChannelRvAdapter rvAdapter=new ChannelRvAdapter();
//                LinearLayoutManager linearLayoutManager=new LinearLayoutManager(getContext());
//                channelRV.setLayoutManager(linearLayoutManager);
//                channelRV.setAdapter(rvAdapter);
//                channelRV.setLayoutManager(new LinearLayoutManager(getContext()));
//            }
//        });




        return root;
    }
}